package ooday04;
import java.util.Timer;
import java.util.TimerTask;
//匿名内部类的练习---定时器(定时做任务)
public class TimerDemo {
    public static void main(String[] args) {
        Timer timer = new Timer();
        int interval = 5000;
        timer.schedule(new TimerTask() {
            public void run() {
                System.out.println("该上厕所了.....");
            }
        }, interval,interval);















       /* Timer timer = new Timer();
        int interval = 1000;
        timer.schedule(new TimerTask() {
            public void run() {//定时干的事----每1000毫秒自动执行
                System.out.println("该练代码了");
            }
        }, 5000,interval);*/


    }
}
